<include file="Public/header"/>
<body class="body-bg">
<div class="park-header">
    <div class="park-header__title">地址管理</div>
    <div class="park-header__left" onclick="window.location='/Home/User/setting/';">
        <i class="iconfont icon-fanhui"></i>
    </div>
</div>
<div class="container">
    <form>
        <div class="park-address-list">
            <volist name="address_list" id="val">
            <div class="park-address-item">
                <div class="park-address-item-info">
                    <p class="name">{$val.name}&nbsp;&nbsp;{$val.mobile}</p>
                    <p class="address">{$val.address_area}{$val.address}</p>
                </div>
                <div class="park-address-item-edit">
                    <div class="left">
                        <label class="park-form" onclick="change_default(this,{$val.id});">
                            <input class="park-form__radio" <if condition="$val['is_default'] eq 1">checked data-id="{$val.id}"</if> name="ra" type="radio">
                            <span class="park-form__radioInput"></span>
                            <span class="park-form__text">默认地址</span>
                        </label>
                    </div>
                    <div class="right" onclick="window.location='/Home/User/add_address/act/edit/id/{$val[id]}';">
                        <i class="iconfont icon-bianji"></i>&nbsp;编辑
                    </div>
                    <div class="right" onclick="del_address(this,{$val['id']});">
                        <i class="iconfont icon-delete"></i>&nbsp;删除
                    </div>
                </div>
            </div>
            </volist>
        </div>
    </form>
</div>
<div class="park-address-add" onclick="window.location='/Home/User/add_address/act/add/';"><i class="iconfont icon-jiahao"></i>&nbsp;新增地址</div>
</body>
<script src="__ROOT__/Public/Home/layer/layer.js"></script>
<script>
   function change_default(obj,id){
        if($(obj).find('input').attr('data-id')==id){
            return false;
        }
        $.post('/Home/User/address_default/',{id:id},function(data){
            layer.open({
                content:data.msg
                ,skin: 'msg'
                ,time: 2 //2秒后自动关闭
            });
        },'json');
    }
    function del_address(obj,id){
        layer.open({
            content: '您确定要删除该地址吗？'
            ,btn: ['确定', '取消']
            ,yes: function(index){
                $.post('/Home/User/del_address/',{id:id},function(data){
                    layer.open({
                        content:data.msg
                        ,skin: 'msg'
                        ,time: 2 //2秒后自动关闭
                    });
                    $(obj).parent().parent().remove();
                },'json');
            }
        });
    }
</script>
</html>